<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%--
	auth : Conner
	date : 2012-09-07
	desc : 编辑权限
--%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<jsp:include page="/admin/common/css/style_sub.jsp"></jsp:include>
<script type="text/javascript" src="<%=basePath%>js/public.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>js/lib/validation/css/livevalidation.css" />
<script type="text/javascript" src="<%=basePath%>js/lib/validation/livevalidation.js"></script>
<script type="text/javascript" src="<%=basePath%>js/lib/jquery/jquery-1.7.1.min.js"></script>
<script language="javascript">
$(function(){
	//$("#select1")[0].focus();
	checkAll();
});

function checkAll(){
	var rname = new LiveValidation('rname',{ wait : 500},{onlyOnSubmit:true});
		rname.add( Validate.Presence, {failureMessage: "不能为空!"});
		rname.add( Validate.Length, { maximum: 6 } );

	var box_width = new LiveValidation('box_width',{ wait : 500},{onlyOnSubmit:true});
		box_width.add( Validate.Presence, {failureMessage: "不能为空!"});
		box_width.add( Validate.Length, { maximum: 4 } );
		box_width.add(Validate.Numericality, { notANumberMessage : "请输入数字!"});
		
	var box_height = new LiveValidation('box_height',{ wait : 500},{onlyOnSubmit:true});
		box_height.add( Validate.Presence, {failureMessage: "不能为空!"});
		box_height.add( Validate.Length, { maximum: 4 } );
		box_height.add(Validate.Numericality, { notANumberMessage : "请输入数字!"});

	var code = new LiveValidation('code',{ wait : 500},{onlyOnSubmit:true});
		code.add( Validate.Presence, {failureMessage: "不能为空!"});
		code.add( Validate.Length, { maximum: 166 } );
		
	var remark = new LiveValidation('remark',{ wait : 500},{onlyOnSubmit:true});
		remark.add( Validate.Presence, {failureMessage: "不能为空!"});
		remark.add( Validate.Length, { maximum: 33 } );
}

function setValue(val){
	G("subSystemId").value = val;
}

//选择父节点
function chooseFRight(){
	var subSysId;  //所属子系统id
	var arr;
	subSysId = G("subSystemId").value;
	if(subSysId == "0" || subSysId != ""){
		var result = window.showModalDialog("<%=basePath %>admin/basic/system/right/right_choose.jsp?time=" + 
				new Date(), subSysId, "dialogWidth:220px; dialogHeight:411px; status:no; resizable:yes;");
		if(typeof(result) == 'string'){
			arr = result.split(",");
			//alert(arr[0]+","+arr[1]+","+arr[2]);
			$("#parentId").val(arr[0]);
			$("#parentName").val(arr[1]);
			setLevel(arr[2]);
		}
	}else{
		alert("请先选择所属子系统");
		G("select1").focus();
	}
}

//切换tr的显示/隐藏
function switchTr(id){
	if(id == 1){
		G("th1").style.display = "block";
		G("td1").style.display = "block";
		G("th2").style.display = "none";
		G("td2").style.display = "none";
	}else if(id == 2){
		G("th2").style.display = "block";
		G("td2").style.display = "block";
		G("th1").style.display = "none";
		G("td1").style.display = "none";
	}
}
function setLevel(flevel){
	var level;
	var str;
	level = Number(flevel) + 1;  //层级  = 父节点层级  + 1
	if(level == 1){
		str = "根菜单";
	}else if(level == 2){
		str = "一级功能";
	}else if(level == 3){
		str = "二级功能";
	}else if(level == 4){
		str = "三级功能";
	}else if(level == 5){
		str = "四级功能";
	}else{
		str = "根菜单";
		level = 1;
	}
	G("leveld").innerHTML = "层级：" + str;
	G("rightLevel").value = level;
}
//显示权限层级
function showRightLevel(level){
	var str;
	if(level == 1){
		str = "根菜单";
	}else if(level == 2){
		str = "一级功能";
	}else if(level == 3){
		str = "二级功能";
	}else if(level == 4){
		str = "三级功能";
	}else if(level == 5){
		str = "四级功能";
	}else{
		str = "根菜单";
		level = 1;
	}
	G("leveld").innerHTML = "层级：" + str;
}
</script>
</head>
<body onload='javascript:showRightLevel(<s:property value="%{right.level_ }"/>);'>
	<div class="title">编辑权限</div>
	<form action="<%=basePath %>basic/sys/right_update.action" id="form" method="post">
		<div class="editorTab">
			<table>
				<tbody>
					<tr>
						<th><font>*</font>所属子系统</th>
						<td>
							<select name="right.sub_id" id="select1" class="downMenu" 
								onchange="javascript:setValue(this.options[this.options.selectedIndex].value);">
								<option value="0">===请选择===</option>
								<s:iterator value="%{listSubSystem}" id="ss">
									<option value="${id }" 
										<s:if test="#ss.id == right.sub_id">selected="selected"</s:if>>${name }</option>
								</s:iterator>
							</select>
							<input type="hidden" id="subSystemId" value='<s:property value="%{right.sub_id }"/>'/>
							<input type="hidden" name="right.id" id="id" value='<s:property value="%{right.id }"/>'/>
						</td>
						<th><font>*</font>所属父节点</th>
						<td>
							<div style="display:inline;float:left;">
								<a href="javascript:void(0);" onclick="javascript:chooseFRight();" title="点击选择">
									<input type="text" id="parentName" 
										value='<s:property value="%{right.parent_name }"/>' readonly="readonly"/>
									<input type="hidden" name="right.parent_id" 
										value='<s:property value="%{right.parent_id }"/>' id="parentId"/>
									<img src="<%=basePath%>style/images/ico_11.gif" align="absmiddle"/>
								</a>&nbsp;&nbsp;
							</div>
							<div id="leveld" style="display:inline;float:left;"></div>
							<input type="hidden" name="right.level_" 
								value='<s:property value="%{right.level_ }"/>' id="rightLevel" />
						</td>
					</tr>
					<tr>
						<th><font>*</font>菜单名称</th>
						<td>
							<input type="text" name="right.name" id="rname" 
								value='<s:property value="%{right.name }"/>'/>
						</td>
						<th><font>*</font>同级排序号</th>
						<td>
							<select name="right.order_" class="downMenu">
								<option value="0">===请选择===</option>
								<option value="0" <s:if test="%{right.order_ == 0}">selected="selected"</s:if>>0</option>
								<option value="1" <s:if test="%{right.order_ == 1}">selected="selected"</s:if>>1</option>
								<option value="2" <s:if test="%{right.order_ == 2}">selected="selected"</s:if>>2</option>
								<option value="3" <s:if test="%{right.order_ == 3}">selected="selected"</s:if>>3</option>
								<option value="4" <s:if test="%{right.order_ == 4}">selected="selected"</s:if>>4</option>
								<option value="5" <s:if test="%{right.order_ == 5}">selected="selected"</s:if>>5</option>
								<option value="6" <s:if test="%{right.order_ == 6}">selected="selected"</s:if>>6</option>
								<option value="7" <s:if test="%{right.order_ == 7}">selected="selected"</s:if>>7</option>
								<option value="8" <s:if test="%{right.order_ == 8}">selected="selected"</s:if>>8</option>
								<option value="9" <s:if test="%{right.order_ == 9}">selected="selected"</s:if>>9</option>
								<option value="10" <s:if test="%{right.order_ == 10}">selected="selected"</s:if>>10</option>
								
								<option value="11" <s:if test="%{right.order_ == 11}">selected="selected"</s:if>>11</option>
								<option value="12" <s:if test="%{right.order_ == 12}">selected="selected"</s:if>>12</option>
								<option value="13" <s:if test="%{right.order_ == 13}">selected="selected"</s:if>>13</option>
								<option value="14" <s:if test="%{right.order_ == 14}">selected="selected"</s:if>>14</option>
								<option value="15" <s:if test="%{right.order_ == 15}">selected="selected"</s:if>>15</option>
								<option value="16" <s:if test="%{right.order_ == 16}">selected="selected"</s:if>>16</option>
								<option value="17" <s:if test="%{right.order_ == 17}">selected="selected"</s:if>>17</option>
								<option value="18" <s:if test="%{right.order_ == 18}">selected="selected"</s:if>>18</option>
								<option value="19" <s:if test="%{right.order_ == 19}">selected="selected"</s:if>>19</option>
								<option value="20" <s:if test="%{right.order_ == 20}">selected="selected"</s:if>>20</option>
								
								<option value="21" <s:if test="%{right.order_ == 21}">selected="selected"</s:if>>21</option>
								<option value="22" <s:if test="%{right.order_ == 22}">selected="selected"</s:if>>22</option>
								<option value="23" <s:if test="%{right.order_ == 23}">selected="selected"</s:if>>23</option>
								<option value="24" <s:if test="%{right.order_ == 24}">selected="selected"</s:if>>24</option>
								<option value="25" <s:if test="%{right.order_ == 25}">selected="selected"</s:if>>25</option>
								<option value="26" <s:if test="%{right.order_ == 26}">selected="selected"</s:if>>26</option>
								<option value="27" <s:if test="%{right.order_ == 27}">selected="selected"</s:if>>27</option>
								<option value="28" <s:if test="%{right.order_ == 28}">selected="selected"</s:if>>28</option>
								<option value="29" <s:if test="%{right.order_ == 29}">selected="selected"</s:if>>29</option>
								<option value="30" <s:if test="%{right.order_ == 30}">selected="selected"</s:if>>30</option>
								
								<option value="41" <s:if test="%{right.order_ == 41}">selected="selected"</s:if>>41</option>
								<option value="42" <s:if test="%{right.order_ == 42}">selected="selected"</s:if>>42</option>
								<option value="43" <s:if test="%{right.order_ == 43}">selected="selected"</s:if>>43</option>
								<option value="44" <s:if test="%{right.order_ == 44}">selected="selected"</s:if>>44</option>
								<option value="45" <s:if test="%{right.order_ == 45}">selected="selected"</s:if>>45</option>
								<option value="46" <s:if test="%{right.order_ == 46}">selected="selected"</s:if>>46</option>
								<option value="47" <s:if test="%{right.order_ == 47}">selected="selected"</s:if>>47</option>
								<option value="48" <s:if test="%{right.order_ == 48}">selected="selected"</s:if>>48</option>
								<option value="49" <s:if test="%{right.order_ == 49}">selected="selected"</s:if>>49</option>
								<option value="50" <s:if test="%{right.order_ == 50}">selected="selected"</s:if>>50</option>
								
								<option value="61" <s:if test="%{right.order_ == 61}">selected="selected"</s:if>>61</option>
								<option value="62" <s:if test="%{right.order_ == 62}">selected="selected"</s:if>>62</option>
								<option value="63" <s:if test="%{right.order_ == 63}">selected="selected"</s:if>>63</option>
								<option value="64" <s:if test="%{right.order_ == 64}">selected="selected"</s:if>>64</option>
								<option value="65" <s:if test="%{right.order_ == 65}">selected="selected"</s:if>>65</option>
								<option value="66" <s:if test="%{right.order_ == 66}">selected="selected"</s:if>>66</option>
								<option value="67" <s:if test="%{right.order_ == 67}">selected="selected"</s:if>>67</option>
								<option value="68" <s:if test="%{right.order_ == 68}">selected="selected"</s:if>>68</option>
								<option value="69" <s:if test="%{right.order_ == 69}">selected="selected"</s:if>>69</option>
								<option value="70" <s:if test="%{right.order_ == 70}">selected="selected"</s:if>>70</option>
								
								<option value="71" <s:if test="%{right.order_ == 71}">selected="selected"</s:if>>71</option>
								<option value="72" <s:if test="%{right.order_ == 72}">selected="selected"</s:if>>72</option>
								<option value="73" <s:if test="%{right.order_ == 73}">selected="selected"</s:if>>73</option>
								<option value="74" <s:if test="%{right.order_ == 74}">selected="selected"</s:if>>74</option>
								<option value="75" <s:if test="%{right.order_ == 75}">selected="selected"</s:if>>75</option>
								<option value="76" <s:if test="%{right.order_ == 76}">selected="selected"</s:if>>76</option>
								<option value="77" <s:if test="%{right.order_ == 77}">selected="selected"</s:if>>77</option>
								<option value="78" <s:if test="%{right.order_ == 78}">selected="selected"</s:if>>78</option>
								<option value="79" <s:if test="%{right.order_ == 79}">selected="selected"</s:if>>79</option>
								<option value="80" <s:if test="%{right.order_ == 80}">selected="selected"</s:if>>80</option>
								
								<option value="81" <s:if test="%{right.order_ == 81}">selected="selected"</s:if>>81</option>
								<option value="82" <s:if test="%{right.order_ == 82}">selected="selected"</s:if>>82</option>
								<option value="83" <s:if test="%{right.order_ == 83}">selected="selected"</s:if>>83</option>
								<option value="84" <s:if test="%{right.order_ == 84}">selected="selected"</s:if>>84</option>
								<option value="85" <s:if test="%{right.order_ == 85}">selected="selected"</s:if>>85</option>
								<option value="86" <s:if test="%{right.order_ == 86}">selected="selected"</s:if>>86</option>
								<option value="87" <s:if test="%{right.order_ == 87}">selected="selected"</s:if>>87</option>
								<option value="88" <s:if test="%{right.order_ == 88}">selected="selected"</s:if>>88</option>
								<option value="89" <s:if test="%{right.order_ == 89}">selected="selected"</s:if>>89</option>
								<option value="90" <s:if test="%{right.order_ == 90}">selected="selected"</s:if>>90</option>
								
								<option value="91" <s:if test="%{right.order_ == 91}">selected="selected"</s:if>>91</option>
								<option value="92" <s:if test="%{right.order_ == 92}">selected="selected"</s:if>>92</option>
								<option value="93" <s:if test="%{right.order_ == 93}">selected="selected"</s:if>>93</option>
								<option value="94" <s:if test="%{right.order_ == 94}">selected="selected"</s:if>>94</option>
								<option value="95" <s:if test="%{right.order_ == 95}">selected="selected"</s:if>>95</option>
								<option value="96" <s:if test="%{right.order_ == 96}">selected="selected"</s:if>>96</option>
								<option value="97" <s:if test="%{right.order_ == 97}">selected="selected"</s:if>>97</option>
								<option value="98" <s:if test="%{right.order_ == 98}">selected="selected"</s:if>>98</option>
								<option value="99" <s:if test="%{right.order_ == 99}">selected="selected"</s:if>>99</option>
								
							</select>
						</td>
					</tr>
					<tr>
						<th><font>*</font>限制访问</th>
						<td>
							<label><input type="radio" name="right.limit_access" value="1" 
								<s:if test="%{right.limit_access == 1}">checked="checked"</s:if>/>是</label>&nbsp;&nbsp;
							<label><input type="radio" name="right.limit_access" value="2" 
								<s:elseif test="%{right.limit_access == 2}">checked="checked"</s:elseif>/>否</label>
						</td>
						<th><font>*</font>外部访问</th>
						<td>
							<label><input type="radio" name="right.external_access" value="1" 
								<s:if test="%{right.external_access == 1}">checked="checked"</s:if>/>允许</label>&nbsp;&nbsp;
							<label><input type="radio" name="right.external_access" value="2" 
								<s:elseif test="%{right.external_access == 2}">checked="checked"</s:elseif>/>不允许</label>
						</td>
					</tr>
					<tr>
						<th><font>*</font>是否控制子资源权限</th>
						<td>
							<label><input type="radio" name="right.filter_subres" value="1" 
								<s:if test="%{right.filter_subres == 1}">checked="checked"</s:if>/>是</label>&nbsp;&nbsp;
							<label><input type="radio" name="right.filter_subres" value="2" 
								<s:elseif test="%{right.filter_subres == 2}">checked="checked"</s:elseif>/>否</label>
						</td>
						<th><font>*</font>类型</th>
						<td>
							<label><input type="radio" name="right.r_type" value="1" 
								<s:if test="%{right.r_type == 1}">checked="checked"</s:if>/>菜单</label>&nbsp;&nbsp;
							<label><input type="radio" name="right.r_type" value="2" 
								<s:elseif test="%{right.r_type == 2}">checked="checked"</s:elseif>/>按钮</label>
						</td>
					</tr>
					<tr>
						<th><font>*</font>叶子节点</th>
						<td>
							<label><input type="radio" name="right.is_leaf" value="1" 
								<s:if test="%{right.is_leaf == 1}">checked="checked"</s:if>/>是</label>&nbsp;&nbsp;
							<label><input type="radio" name="right.is_leaf" value="2" 
								<s:elseif test="%{right.is_leaf == 2}">checked="checked"</s:elseif>/>否</label>
						</td>
						<th><font>*</font>当前状态</th>
						<td>
							<label><input type="radio" name="right.r_status" value="1" 
								<s:if test="%{right.r_status == 1}">checked="checked"</s:if>/>启用</label>&nbsp;&nbsp;
							<label><input type="radio" name="right.r_status" value="2" 
								<s:elseif test="%{right.r_status == 2}">checked="checked"</s:elseif>/>禁用</label>
						</td>
					</tr>
					<tr>
						<th><font>*</font>打开模式</th>
						<td>
							<label><input type="radio" name="right.open_mode" value="1" 
								<s:if test="%{right.open_mode == 1}">checked="checked"</s:if> 
								onclick="javascript:switchTr(1);"/>弹出式</label>&nbsp;&nbsp;
							<label><input type="radio" name="right.open_mode" value="2" 
								<s:elseif test="%{right.open_mode == 2}">checked="checked"</s:elseif> 
								onclick="javascript:switchTr(2);"/>非弹出式</label>
						</td>
						<th id="th1" <s:if test="%{right.open_mode == 2}">style="display:none;"</s:if>>
							<font>*</font>弹出框窗口宽高(W*H)(像素)</th>
						<td id="td1" <s:if test="%{right.open_mode == 2}">style="display:none;"</s:if> colspan="3">
							<input type="text" name="right.box_width" id="box_width" 
								size="4" maxlength="4" value='<s:property value="%{right.box_width }"/>' 
								onclick="javascript:this.select();"/>(W)&nbsp;*&nbsp;
							<input type="text" name="right.box_height" id="box_height" 
								size="4" maxlength="4" value='<s:property value="%{right.box_height }"/>' 
								onclick="javascript:this.select();"/>(H)(像素)
						</td>
						<th id="th2" <s:if test="%{right.open_mode == 1}">style="display:none;"</s:if>>&nbsp;</th>
						<td id="td2" <s:if test="%{right.open_mode == 1}">style="display:none;"</s:if> 
							colspan="3">&nbsp;</td>
					</tr>
					<tr>
						<th><font>*</font>访问地址编码(URL)</th>
						<td>
							<textarea name="right.code" id="code" rows="3" 
								class="downMenu"><s:property value="%{right.code }"/></textarea>
						</td>
						<th>备注</th>
						<td>
							<textarea name="right.remark" id="remark" rows="3" 
								class="downMenu"><s:property value="%{right.remark }"/></textarea>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
	
		<div class="infoTips">
			加"<font>*</font>"的为必选或必填项
		</div>
		
		<div class="btns">
			<span class="btn"><input type="submit" id="submitBtn" value="修改" /></span>
			<span class="btn">
				<input type="button" id="cancelBtn" value="返回" 
					onclick="javascript:window.history.back();"/>
			</span>
		</div>
	</form>
</body>
</html>
